<?php
/**
 * Note: `static` is not allowed in use with compile-time constants
 * @ref https://mp.weixin.qq.com/s?src=11&timestamp=1584889108&ver=2232&signature=ra8vgkS7RyqNtg8PIPPN*q25onbZbVjSF40-9wiF4dkeUB5QR2OEVKWmY-2*ZqT1SxDkWoZf9rUzYnxIrWLGzinaHJtBy*diHD42OgBq8MRngug6dKrJa91M9fVmeiG-&new=1
 * @ref https://www.php.cn/php-weizijiaocheng-433069.html
 */

function out($str = null)
{
    echo $str, PHP_EOL;
}

class A
{
    public static $var1 = 'A';

    public static function echo()
    {
        out(self::$var1);
        out(static::$var1);
    }

    public static function newSelf()
    {
        return new self;
    }

    public static function newStatic()
    {
        return new static;
    }
}

class B extends A
{
    public static $var1 = 'B';
}

function main()
{
    B::echo();

    out();

    out(get_class(A::newSelf()));
    out(get_class(A::newStatic()));

    out();

    out(get_class(B::newSelf()));
    out(get_class(B::newStatic()));
}

main();
